<template>
	<view class="main">
		<!-- <rich-text :nodes="agreementInfo.agreement"></rich-text> -->
		<!-- <mp-html :content="agreementInfo.agreement" /> -->
		<!-- <mp-html :content="agreementInfo" /> -->
		<rich-text :nodes="agreementInfo"></rich-text>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				agreementInfo: null
			};
		},
		onLoad(info) {
			uni.showLoading({
				mask: true
			})
			console.log(info)
			this.getAgreement(info.name);
			uni.hideLoading()
		},
		methods: {
			getAgreement(name) {
				let picServiceUrl = app.globalData.picServiceUrl
				let rootDir = app.globalData.fileRootDir
				var that = this;
				// 在uni-app页面中的方法中使用uni.request获取txt文件内容
				uni.request({
					url: picServiceUrl + rootDir + '/agreement/' + name,
					success: (res) => {
						// 将获取到的txt文件内容赋值给data中的变量，用于页面展示
						that.agreementInfo = res.data;
						console.log(JSON.stringify(res));
						console.log(JSON.stringify(that.agreementInfo));
					},
					fail: (err) => {
						console.error('获取文件失败', err);
					}
				});
			}
		}
	};
</script>
<style scoped>
	.main {
		padding: 10px;
	}
</style>